import type { UploadUserFile } from "element-plus";
import { type } from "os";
export interface GetSpuListParams {
  page: number;
  limit: number;
  category3Id: number;
}
/* 
 {
    "records": [
      {
        "id": 9453,
        "spuName": "1223",
        "description": "12",
        "category3Id": 1,
        "tmId": 6,
        "spuSaleAttrList": null,
        "spuImageList": null
      }
    ],
    "total": 4,
    "size": 1,
    "current": 1,
    "searchCount": true,
    "pages": 4
  },
  "ok": true
}
*/

export interface SpuItem {
  id: number;
  spuName: string;
  description: string;
  tmId: number;
}

export type SpuList = SpuItem[];

export interface GetSpuListResponse {
  total: number;
  records: SpuList;
}

export interface BaseSaleAttrItem {
  id: number;
  name: string;
}

export type BaseSaleAttrList = BaseSaleAttrItem[];

// 添加属性类型
export interface SpuSaleAttrValueItem {
  baseSaleAttrId: number;
  saleAttrValueName: string;
  id?: number;
}

export type SpuSaleAttrValueList = SpuSaleAttrValueItem[];

export interface SpuSaleAttrItem {
  baseSaleAttrId: number;
  saleAttrName: string;
  spuSaleAttrValueList: SpuSaleAttrValueList;
  isEdit?: boolean;
  id?: number;
}

export type SpuSaleAttrList = SpuSaleAttrItem[];

// 公共类型
export interface SpuSaveInfo {
  id?: number;
  spuName: string;
  description: string;
  spuSaleAttrList: SpuSaleAttrList;
}

// 添加或修改需要的图片类型
export interface SpuImageItem {
  id?: number;
  imgName: string;
  imgUrl: string;
}
export type SpuImageList = SpuImageItem[];

// 组件中需要的类型
export interface SpuCompontent extends SpuSaveInfo {
  tmId: number | undefined;
  spuImageList: UploadUserFile[];
}

// 请求或添加需要的类型
export interface SpuSaveOrUpdate extends SpuSaveInfo {
  spuImageList: SpuImageList;
  category3Id: number;
  tmId: number;
  /* 
  id?: number;
  spuName: string;
  description: string;
  spuSaleAttrList: SpuSaleAttrList;
  */
}

/******************************** 添加SKU ***********************************/

export interface SkuAttrValueItme {
  attrId: number;
  attrName: string;
  id?: number;
  valueId: number;
  valueName: string;
}

export type SkuAttrValueList = SkuAttrValueItme[];

export interface SkuSaleAttrValueItem {
  id?: number;
  saleAttrId: number;
  saleAttrName: string;
  saleAttrValueId: number;
  saleAttrValueName: string;
}

export type SkuSaleAttrValueList = SkuSaleAttrValueItem[];

export interface SkuImageItem extends SpuImageItem {
  /* 
  id?: number;
  imgName: string;
  imgUrl: string;
  */
  isDefault?: string;
}

export type SkuImageList = SkuImageItem[];

// 组件使用类型
export interface Comment {
  skuName: string;
  price: number;
  weight: number;
  skuDesc: string;
  skuAttrValueList: Array<string | undefined>;
  skuSaleAttrValueList: Array<string | undefined>;
  skuImageList: SkuImageList;
  skuDefaultImg: string;
}

export interface SkuAttr
  extends Omit<Comment, "skuAttrValueList" | "skuSaleAttrValueList"> {
  category3Id: number;
  id?: number;
  spuId: number;
  isSale?: number;
  skuSaleAttrValueList: SkuSaleAttrValueList;
  skuAttrValueList: SkuAttrValueList;
}
